package com.snowfield.lbmonitor.serverStatus;

import java.util.HashMap;

/**
 * 管理状态
 */
public class SrvAdminState {
    private final Integer adminState;
    private final String status;
    private final String desc;

    private static final HashMap<Integer, SrvAdminState> srvAdminStateMap = new HashMap();

    static {
        srvAdminStateMap.put(0, new SrvAdminState(0, "NORMAL", "normal"));
        srvAdminStateMap.put(0x01, new SrvAdminState(0x01, "FMAINT", "The server was explicitly forced into maintenance"));
        srvAdminStateMap.put(0x02, new SrvAdminState(0x02, "IMAINT", "The server has inherited the maintenance status from a tracked server"));
        srvAdminStateMap.put(0x04, new SrvAdminState(0x04, "CMAINT", "The server is in maintenance because of the configuration"));
        srvAdminStateMap.put(0x08, new SrvAdminState(0x08, "FDRAIN", "The server was explicitly forced into drain state"));
        srvAdminStateMap.put(0x10, new SrvAdminState(0x10, "IDRAIN", "The server has inherited the drain status from a tracked server"));
        srvAdminStateMap.put(0x20, new SrvAdminState(0x20, "RDRAIN", "The server is in maintenance because of an IP address resolution failure"));
        srvAdminStateMap.put(0x40, new SrvAdminState(0x40, "HMAINT", "The server FQDN was set from stats socket"));
    }

    private SrvAdminState(Integer adminState, String status, String desc) {
        this.adminState = adminState;
        this.status = status;
        this.desc = desc;
    }

    public static SrvAdminState getInstance(Integer adminState) {
        return srvAdminStateMap.get(adminState);
    }

    public Integer getAdminState() {
        return adminState;
    }

    public String getStatus() {
        return status;
    }

    public String getDesc() {
        return desc;
    }
}
